package com.example.mansystem.controller;


import com.example.mansystem.dto.ChangeDepartmentDto;
import com.example.mansystem.dto.ChangePlaceDto;
import com.example.mansystem.entity.CallResultMsg;
import com.example.mansystem.entity.PlaceDO;
import com.example.mansystem.exception.UniformReponseHandler;
import com.example.mansystem.mapper.PlaceMapper;
import com.example.mansystem.service.PlaceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/place")
public class PlaceController {
    @Autowired
    PlaceMapper placeMapper;
    @Autowired
    PlaceService placeService;

    @GetMapping("/allplace")
    public CallResultMsg GetAllPlace()
    {
        List<PlaceDO> res=placeMapper.selectList(null);
        return new UniformReponseHandler<List<PlaceDO>>().sendSuccessResponse(res);
    }



    @PostMapping("/change")
    public CallResultMsg ChangeDepartment(@RequestBody @Validated ChangePlaceDto validator)
    {
        placeService.ChangePlace(validator);
        return new UniformReponseHandler<String>().sendSuccessResponse("SUCCESS");
    }
}
